package models

import (
	"gorm.io/gorm/schema"
	"time"
)

type Article struct {
	Id int64 `json:"id" gorm:"primaryKey"`
	SqlTimeFields

	Title        string     `json:"title" gorm:"type:varchar(128);"`
	SubTitle     string     `json:"sub_title" gorm:"type:varchar(256)"`
	Describe     string     `json:"describe" gorm:"type:varchar(512)"` //简介
	Cover        string     `json:"cover" gorm:"type:varchar(256)"`    //封面
	Author       string     `json:"author" gorm:"type:varchar(128)"`
	Hits         int64      `json:"hits" gorm:"type:int"`
	Sort         int        `json:"sort" gorm:"type:int"`
	PublishStart *time.Time `json:"publish_start"` //发布时间开始
	PublishEnd   *time.Time `json:"publish_end"`   //发布时间结束
	ContentId    int64      `json:"content_id"`    //对应内容记录id
	Extends      string     `json:"extends" gorm:"type:varchar(512)"`
	Status       int        `json:"status"` //0:无,1:可用,2：禁用
}

func (a *Article) TableName(namer schema.Namer) string {
	return namer.TableName("article")
}

type ArticleContent struct {
	Id int64 `json:"id" gorm:"primaryKey"`
	SqlTimeFields

	Renderer string `json:"renderer" gorm:"type:varchar(20)"` //渲染方式，如：richtext，html，markdown，string等
	Content  string `json:"content" gorm:"type:text"`
}

func (a *ArticleContent) TableName(namer schema.Namer) string {
	return namer.TableName("article_content")
}
